<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="用户名称" prop="createUserName">
        <el-input
          v-model="queryParams.createUserName"
          placeholder="请输入用户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="upgradeList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" align="center" />
      <el-table-column label="用户名" align="center" prop="createUserName" />
      <el-table-column label="企业名称" align="center" prop="enterpriseName" />
      <el-table-column label="国家/地区" align="center" prop="countryName" />
      <el-table-column label="通知时间" align="center">
        <template slot-scope="scope">
            <span v-if="scope.row.createTime!= null">
              {{ parseTime(scope.row.createTime ) }}
            </span>
        </template>
      </el-table-column>
      <el-table-column label="支付方式" align="center" prop="paymentMethod" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="流水号" align="center" prop="serialNumber" />
      <el-table-column label="付款费用" align="center" prop="paymentFees" />
      <el-table-column label="币种" align="center" prop="currency" />
      <el-table-column label="凭证" align="center" prop="voucher" >
        <template slot-scope="scope">
          <img :src="scope.row.voucher" height="80" width="100" @click="openImg(scope.row)">
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="1000px">
      <div style="text-align: center"><img :src="imgUrl" height="500" style="max-width: 100%"></div>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listUpgrade, getUpgrade, delUpgrade, addUpgrade, updateUpgrade } from "@/api/system/upgrade";

export default {
  name: "Upgrade",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 升级服务表格数据
      upgradeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        createUserName: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        paymentFees: [
          { required: true, message: "付款费用不能为空", trigger: "blur" }
        ],
      },
      imgUrl:"",
      dialogVisible:false
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询升级服务列表 */
    getList() {
      this.loading = true;
      listUpgrade(this.queryParams).then(response => {
        this.upgradeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        enterpriseId: null,
        serialNumber: null,
        paymentMethod: null,
        paymentFees: null,
        remark: null,
        voucher: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        createUserName: null,
        countryName: null,
        currency: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 凭证弹窗 */
    openImg(row) {
      this.imgUrl = row.voucher;
      this.dialogVisible = true;
    }
  }
};
</script>
